<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>公交查询</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-cache" />
  
  <meta http-equiv="Pragma" content="no-cache"> 
<meta http-equiv="Expires" content="0"> 

<link rel="alternate icon" type="image/png" href="assets/i/favicon.png">

<link rel="stylesheet" href="assets/css/amaze.min.css">
<link rel="stylesheet" href="assets/css/amazeui.min.css">
<link rel="stylesheet" href="assets/fonts2/iconfont.css">
<link rel="stylesheet" href="assets/css/app.css">
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/handlebars.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
<style>
body{
	padding-bottom:50px;
	position:static;
}
	
.am-content {
	background: #FFFFFF;
}

.am-tabs {
	margin: 0px;
}

#sites {
	border: 0px;
	padding: 0 1rem;
	border-top: 1px solid #d6d6d6;
	overflow: hidden;
}

.item {
	line-height: 45px;
	height: 45px;
}

.item .no {
	float: left;
	width: 10%;
}

.item .radius {
	border-radius: 100%;
	background-color: #e2e5e6;
	width: 20px;
	height: 20px;
	line-height: 20px;
	text-align: center;
	font-size: .8rem;
	color: #ffffff;
	margin-top: 15px;
	position: relative;
    z-index: 99;
}

.item .site {
	float: left;
	width: 90%;
	border-bottom: 1px solid #EFEEEE;
	font-size: 1.5rem;
	color: #3d4245;
}

.item .site-gray {
	color: #9b9b9b;
}

.item .site-highligh {
	color: #fab34d;
}

.item .highligh {
	background: #fab34d;
}

.demo-bar,.am-tabs-default .am-tabs-nav {
	z-index: 99;
	position: relative;
}

.h-line {
	height: 95%;
	width: 1px;
	position: absolute;
	background-color: #EFEEEE;
	z-index: 9;
	top: 270px;
	bottom:20px;
	left: 21px;
}

.am-tabs-default .am-tabs-nav>.am-active a {
	background-color: #FFFFFF;
	color: #5eacf6;
}

.am-tabs-default .am-tabs-nav {
	padding: .5rem 0px;
	background-color: #ffffff;
}

.am-tabs-default .am-tabs-nav a {
	background-color: #FFFFFF;
}

.am-tabs-nav li {
	border-left: 1px solid #e2e5e6;
}

.am-tabs-default .am-tabs-nav a {
	line-height: 26px;
	font-size: 1.3rem;
	color: #9b9b9b;
}

.icon-jiantou {
	font-size: 1rem;
}

.bus {
	color: #5eacf6;
	float: right;
	font-size: 1.4rem;
}
.footer{
	position: fixed;
	bottom:0;
	left:0;
	width:100%;
	z-index:100;
	background-color:#f5f5f5;
	border-top:1px solid #EFEEEE;
	height:50px;
	padding:0px 2%;
}
.head{
	position:absolute;
	top:0;
	left:0;
	width:100%;
	z-index:100;
}
.site {
	font-size:1.8rem !important;
}

.timesche{
	float:right;
	text-align: center;
	width:45%;
}

.timesche ul{
	list-style:none;
}

.timesche li{
	line-height:50px;
}

.exchange{
	margin-right:10px;
	float:right;
	padding:10px 0;
}

.exchange ul{
 list-style: none;
}

.exchange li{
	float:left;
}

.nextDistance ul{
	list-style: none;
}

.nextDistance li{
	list-style: none;
	line-height:50px;
	color:#f4c600;
}
</style>

</head>
<body>
	<header class="demo-bar head">
		<a href="javascript:void(0);" onclick="$('#sy').click();" id="back2"
			class="icon iconfont icon-left demo-icon-home"></a>
		<h1 id="title"></h1>
	</header>
	<div style="border-bottom: 1px solid #EFEEEE; padding:10px;margin-top:50px;">
		<div style="margin-left:10px;float:left;">
			<div>开往<span id="goto"></span></div>
			<div style="font-size:1.4rem;color:#9d9d9d;" id="firstLastCar">首末班车：</div>
			<div style="font-size:1.4rem;color:#9d9d9d;" id="allprice">全程票价：元</div>
		</div>
		<div class="exchange">
			<ul>
				<li><img src="images/exchange.png" width="25px" height="25px" onclick="changeTarget();"/>&nbsp;</li>
				<li style="border:1px solid #cccccc; height:30px;"></li>
				<li>&nbsp;<img src="images/qxshouc.png" width="25xp" height="25px" onclick="shouc(this)"/>
				<img src="images/shouc.png" width="25xp" height="25px" onclick="qxshouc(this)" style="display:none;"/></li>
			</ul>
		</div>
		<div style="clear:both;"></div>
	</div>
	<div style="border-bottom: 1px solid #EFEEEE; text-align:center;height:100px;line-height:100px;">
		<div style="float:left;text-align: center;width:45%;">
			<ul id="nextDistance" class="nextDistance">
				<li style="margin-bottom:-15px;margin-top:15px;">
					<font id="distance" style="font-size:25px;"></font>
					米
				</li>
				<li>即将到站</li>
			</ul>
			<span id="distanceMessege" style="color:#f4c600;"></span>
		</div>
		<span style="border:1px solid;margin:10px;color:#cccccc"></span>
		<div class="timesche">
			<ul>
				<li style="margin-bottom:-15px;margin-top:15px;color:rgb(26, 125, 226);font-size:1.8rem;">
					<span id="site">站</span>/<span id="km">m</span>
				</li>
				<li>
					<span id="schedule" style="background-color:rgb(26, 125, 226);padding:5px 20px;
						border-radius:5px;color:white;margin-left:5px;">
						<img src="images/clock.png" alt="时刻表" border="0" width="25px" height="25px" style="line-height:25px;
						margin:5px auto 10px;"/>
						时刻表
					</span>
				</li>
			</ul>
		</div>		
	</div>
	<div style="background-color:#f5f5f5;line-height:10px;height:10px;"></div>
	<div id="sites"></div>
	<div class="h-line" style=""></div>
		<footer class="footer">
		<div id="sy" style="width:32%;float:left;text-align:center;color:#1a7de2;">
			<ul style="list-style:none;">
				<li><i class="icon iconfont icon-bus" style="font-size:24px;line-height:30px;top:0px;"></i></li>
				<li style="line-height:15px;"><span style="font-size:12px;">线路查询</span></li>
			</ul>
		</div>
		<div id="xlgh" style="width:32%;float:left;text-align:center;color:#9b9b9b;">
			<ul style="list-style:none;">
				<li><i class="icon iconfont icon-guiji" style="font-size:24px;line-height:30px;top:0px;"></i></li>
				<li style="line-height:15px;"><span style="font-size:12px;">线路规划</span></li>
			</ul>
		</div>
		<div id="wdsc" style="width:32%;float:left;text-align:center;color:#9b9b9b;">
			<ul style="list-style:none;">
				<li><i class="icon iconfont icon-user" style="font-size:22px;line-height:30px;top:0px;"></i></li>
				<li style="line-height:15px;"><span style="font-size:12px;">我的收藏</span></li>
			</ul>
		</div>
	</footer>
	
	<script>
		var handleHelper = Handlebars.registerHelper("addOne",function(index){
			return index+1;
      	});
	</script>
	<script id="list-site-templ" type="text/x-handlebars-template">
      {{#each result}}
			<div class="item" data-siteId = "{{siteId}}" data-siteName = "{{siteName}}">
				<div class="no">
					<div class="radius">{{addOne @index}}</div>
				</div>
				<div class="site">
					<span>{{siteName}}</span>
					<div class="bus"></div>
				</div>
			</div>
      {{/each}}
	</script>


	<script type="text/javascript">		
		var query = $.getLocationQueryData();
		var longitude = query.longitude;
		var latitude = query.latitude;
		var lineId = query.lineId;
		var stream = query.stream;
		var qsiteId = query.siteId;
		var siteName = unescape(query.siteName);
		var phone=query.phone;
		
		function flushLineStatus(lineId) {
			var url = 'taxi/json/nanda?url='+escape("getWebLineBusStatus.action?lineId="+lineId);
			var params = {};
			var currItem = $('.item[data-siteName="' + siteName + '"]:first');
			var currIndex = currItem.index();
			var currSiteId = currItem.attr("data-siteId");
			
			//当前我所在站点标黄
			var firstItem = $('.item:first');
			var lastItem = $('.item:last');
			var thisStream = firstItem.find(".site span").html() + "--" + lastItem.find(".site span").html();
			if(currIndex>=0){
				$('.item .site:gt(' + currIndex + ')').addClass('site-gray');
				$('.item .site:eq(' + currIndex + ')').addClass('site-highligh');
				$('.item .radius:eq(' + currIndex + ')').addClass('highligh');
			}
			
			$.request(url,params,function(data) {
				//var data = "{\"message\":\"success\",\"result\":[{\"stream\":\"汽车总站--汽车东站\",\"lineId\":null,\"siteId\":\"10\",\"siteName\":\"人民医院\",\"intStream\":null,\"onlines\":1,\"carNo\":\"苏DLL523\"},{\"stream\":\"汽车总站--汽车东站\",\"lineId\":null,\"siteId\":\"6\",\"siteName\":\"江南春\",\"intStream\":null,\"onlines\":1,\"carNo\":\"苏DLL527\"},{\"stream\":\"汽车东站--汽车总站\",\"lineId\":null,\"siteId\":\"5\",\"siteName\":\"电影院\",\"intStream\":null,\"onlines\":1,\"carNo\":\"苏DLL539\"},{\"stream\":\"汽车总站--汽车东站\",\"lineId\":null,\"siteId\":\"4\",\"siteName\":\"公安局\",\"intStream\":null,\"onlines\":1,\"carNo\":\"苏DLL551\"},{\"stream\":\"汽车东站--汽车总站\",\"lineId\":null,\"siteId\":\"11\",\"siteName\":\"汽车总站\",\"intStream\":null,\"onlines\":1,\"carNo\":\"苏DLL507\"},{\"stream\":\"汽车东站--汽车总站\",\"lineId\":null,\"siteId\":\"9\",\"siteName\":\"人民广场\",\"intStream\":null,\"onlines\":1,\"carNo\":\"苏DLL521\"}],\"retCode\":\"0\"}";
				data = JSON.parse(data);
				if (data.retCode != 0
						|| data.result.length == 0) {
					return;
				}
				
				$('.item .site .bus').html("");
				for(var i=0;i<data.result.length;i++){
					//绘制已经到站的公交
					var busStatus = data.result[i];
					if(thisStream == busStatus.stream && busStatus.onlines==1){
						var siteId = busStatus.siteId;
						var carNo = busStatus.carNo;
						var item = $('.item[data-siteid="' + siteId + '"]:first');
						var index = item.index();
						if(currIndex == index) {
							var oldHtml = $('.item .site .bus:eq(' + (index-1) + ')').html();
							if(oldHtml=='') {
								$('.item .site .bus:eq(' + (index-1) + ')').html('即将到站<i class="icon iconfont icon-bus"></i>'+carNo);
							} else {
								$('.item .site .bus:eq(' + (index-1) + ')').html(oldHtml + '<i class="icon iconfont icon-bus"></i>'+carNo);
							}
						} else {
							if(currIndex == index-1) {
								var oldHtml = $('.item .site .bus:eq(' + (index-1) + ')').html();
								if(oldHtml=='') {
									$('.item .site .bus:eq(' + (index-1) + ')').html('已经到达<i class="icon iconfont icon-bus"></i>'+carNo);
								} else {
									$('.item .site .bus:eq(' + (index-1) + ')').html(oldHtml + '<i class="icon iconfont icon-bus"></i>'+carNo);
								}
							} else {
								var oldHtml = $('.item .site .bus:eq(' + (index-1) + ')').html();
								$('.item .site .bus:eq(' + (index-1) + ')').html(oldHtml + '<i class="icon iconfont icon-bus"></i>'+carNo);
							}
						}
					}
				}
			});
		
			if(currIndex>=0){
				//最近的车距离
				url = "taxi/json/nanda?url="+escape("getNearestBus.action?lineId="+lineId+"&siteId="+currSiteId+"&stream="+stream);
				params={};
				$.request(url,params,function(data) {
					data = JSON.parse(data);
					//var data = {"retCode":0, "result":268};
					if(data.retCode != 0){
						$('#nextDistance').hide();
						$("#km").html('m');
						$("#site").html('站');
						$('#distanceMessege').html("附近暂无班车");
						$('#distanceMessege').show();
						return;
					}
					if(data.result.redistance>0){
						var distance = data.result.redistance;
						$("#distance").html(distance);
						$("#site").html(data.result.site + "站");
						if(distance<1000){
							$("#km").html(distance+"m");
						} else {
							$("#km").html((distance/1000).toFixed(1)+"km");
						}
						$("#distance").show();
						$('#distanceMessege').hide();
					} else {
						$('#nextDistance').hide();
						$("#km").html('m');
						$("#site").html('站');
						$('#distanceMessege').html("附近暂无班车");
						$('#distanceMessege').show();
					}
				}); 
			} else {
				$('#nextDistance').hide();
				$("#km").html('m');
				$("#site").html('站');
				$('#distanceMessege').html("附近暂无班车");
				$('#distanceMessege').show();
			}
		}

		function flushSites(lineId,stream) {
			var url = 'taxi/json/nanda?url='+escape("getSiteByLine.action?lineId="+lineId);
			var params = {};
			$.asyncrequest(url, params, function(data) {
				data = JSON.parse(data);
			//var data = {"result":[{"lat":31.43595,"lineId":"1","lineStreamSite":"266dee6e-4892-48f8-8b9d-2c7515cbc462","lon":119.47888,"orderNo":8,"relationId":"266dee6e-4892-48f8-8b9d-2c7515cbc462","siteId":"20","siteName":"凤凰宾馆","stream":0},{"lat":31.418888,"lineId":"1","lineStreamSite":"cbb33bb1-f91a-4243-99cc-65fcff4f580e","lon":119.47815,"orderNo":4,"relationId":"cbb33bb1-f91a-4243-99cc-65fcff4f580e","siteId":"24","siteName":"燕山南村","stream":0},{"lat":31.413961,"lineId":"1","lineStreamSite":"2a2db9dc-b936-4da3-be71-4a13b6fb92b8","lon":119.47615,"orderNo":26,"relationId":"2a2db9dc-b936-4da3-be71-4a13b6fb92b8","siteId":"2347","siteName":"妇保院","stream":1},{"lat":31.442284,"lineId":"1","lineStreamSite":"001aa9af-ff79-4052-b228-69f229ae0096","lon":119.474365,"orderNo":19,"relationId":"001aa9af-ff79-4052-b228-69f229ae0096","siteId":"230","siteName":"泓口医院","stream":1},{"lat":31.422796,"lineId":"1","lineStreamSite":"e570b92b-4357-4f03-963d-c1ae8956c5b6","lon":119.475555,"orderNo":5,"relationId":"e570b92b-4357-4f03-963d-c1ae8956c5b6","siteId":"1857","siteName":"阳光城市","stream":0},{"lat":31.439194,"lineId":"1","lineStreamSite":"6e040366-3790-462b-9ab8-d9a53af01845","lon":119.47805,"orderNo":9,"relationId":"6e040366-3790-462b-9ab8-d9a53af01845","siteId":"231","siteName":"濑江村","stream":0},{"lat":31.40694,"lineId":"1","lineStreamSite":"997869dc-c8ef-4ea4-b3eb-784ba9468a59","lon":119.47881,"orderNo":28,"relationId":"997869dc-c8ef-4ea4-b3eb-784ba9468a59","siteId":"2518","siteName":"汽车总站","stream":1},{"lat":31.43595,"lineId":"1","lineStreamSite":"2b356e88-775a-4af2-888b-cc5cafa98124","lon":119.47888,"orderNo":21,"relationId":"2b356e88-775a-4af2-888b-cc5cafa98124","siteId":"20","siteName":"凤凰宾馆","stream":1},{"lat":31.454887,"lineId":"1","lineStreamSite":"bffba62b-e82b-4156-ac58-a45276101096","lon":119.463135,"orderNo":13,"relationId":"bffba62b-e82b-4156-ac58-a45276101096","siteId":"15","siteName":"城北工业园","stream":0},{"lat":31.425337,"lineId":"1","lineStreamSite":"19db7b49-4ad3-4eae-b878-76463e00f3d1","lon":119.48322,"orderNo":6,"relationId":"19db7b49-4ad3-4eae-b878-76463e00f3d1","siteId":"2460","siteName":"大统华","stream":0},{"lat":31.448343,"lineId":"1","lineStreamSite":"da6f83fe-bbca-4807-99ec-ec9cd10595e2","lon":119.467186,"orderNo":11,"relationId":"da6f83fe-bbca-4807-99ec-ec9cd10595e2","siteId":"229","siteName":"四中","stream":0},{"lat":31.418888,"lineId":"1","lineStreamSite":"a56267b6-662c-4b46-9db9-d8dc9c6817c8","lon":119.47815,"orderNo":25,"relationId":"a56267b6-662c-4b46-9db9-d8dc9c6817c8","siteId":"24","siteName":"燕山南村","stream":1},{"lat":31.43453,"lineId":"1","lineStreamSite":"05867bc6-9c65-4368-b7e9-cdb12ab0e4d3","lon":119.47845,"orderNo":22,"relationId":"05867bc6-9c65-4368-b7e9-cdb12ab0e4d3","siteId":"126","siteName":"清溪小区","stream":1},{"lat":31.413961,"lineId":"1","lineStreamSite":"f1d3fafd-0094-4303-bcbb-cecf34cd00dc","lon":119.47615,"orderNo":3,"relationId":"f1d3fafd-0094-4303-bcbb-cecf34cd00dc","siteId":"2347","siteName":"妇保院","stream":0},{"lat":31.409693,"lineId":"1","lineStreamSite":"d074e32f-759a-4ae7-b0fc-827a306d923c","lon":119.47499,"orderNo":27,"relationId":"d074e32f-759a-4ae7-b0fc-827a306d923c","siteId":"2348","siteName":"湾里村","stream":1},{"lat":31.40694,"lineId":"1","lineStreamSite":"03458ab1-13a5-45d1-aea7-8b626966c5fe","lon":119.47881,"orderNo":1,"relationId":"03458ab1-13a5-45d1-aea7-8b626966c5fe","siteId":"2518","siteName":"汽车总站","stream":0},{"lat":31.43453,"lineId":"1","lineStreamSite":"38aca855-479b-41cc-aff1-85e56dcb71e4","lon":119.47845,"orderNo":7,"relationId":"38aca855-479b-41cc-aff1-85e56dcb71e4","siteId":"126","siteName":"清溪小区","stream":0},{"lat":31.46146,"lineId":"1","lineStreamSite":"50f220f9-497f-4106-b9ab-9125f00841ca","lon":119.4732,"orderNo":14,"relationId":"50f220f9-497f-4106-b9ab-9125f00841ca","siteId":"14","siteName":"胥泊村","stream":0},{"lat":31.451242,"lineId":"1","lineStreamSite":"6f5a5973-711a-4073-93f4-f73707abe175","lon":119.4637,"orderNo":12,"relationId":"6f5a5973-711a-4073-93f4-f73707abe175","siteId":"228","siteName":"泓口村","stream":0},{"lat":31.448343,"lineId":"1","lineStreamSite":"35b2f8d8-3d46-4999-86b6-4275bcb87acb","lon":119.467186,"orderNo":18,"relationId":"35b2f8d8-3d46-4999-86b6-4275bcb87acb","siteId":"229","siteName":"四中","stream":1},{"lat":31.454887,"lineId":"1","lineStreamSite":"f853d872-bfd2-447b-9c82-a6de01d2fe44","lon":119.463135,"orderNo":16,"relationId":"f853d872-bfd2-447b-9c82-a6de01d2fe44","siteId":"15","siteName":"城北工业园","stream":1},{"lat":31.409693,"lineId":"1","lineStreamSite":"415b86c0-6bad-486b-b815-228263b052d9","lon":119.47499,"orderNo":2,"relationId":"415b86c0-6bad-486b-b815-228263b052d9","siteId":"2348","siteName":"湾里村","stream":0},{"lat":31.425337,"lineId":"1","lineStreamSite":"7b839b0e-3826-491d-9ec0-42a8bd1a8e10","lon":119.48322,"orderNo":23,"relationId":"7b839b0e-3826-491d-9ec0-42a8bd1a8e10","siteId":"2460","siteName":"大统华","stream":1},{"lat":31.439194,"lineId":"1","lineStreamSite":"bb8de4ea-df18-472b-9d28-496709cf6e71","lon":119.47805,"orderNo":20,"relationId":"bb8de4ea-df18-472b-9d28-496709cf6e71","siteId":"231","siteName":"濑江村","stream":1},{"lat":31.442284,"lineId":"1","lineStreamSite":"0d9853c7-cd07-491d-aed7-e4d7bf2a333a","lon":119.474365,"orderNo":10,"relationId":"0d9853c7-cd07-491d-aed7-e4d7bf2a333a","siteId":"230","siteName":"泓口医院","stream":0},{"lat":31.46146,"lineId":"1","lineStreamSite":"3c3679f3-2574-4f20-92b1-c620ce6a6cb7","lon":119.4732,"orderNo":15,"relationId":"3c3679f3-2574-4f20-92b1-c620ce6a6cb7","siteId":"14","siteName":"胥泊村","stream":1},{"lat":31.422796,"lineId":"1","lineStreamSite":"8760369f-46bf-48f1-8822-f5b5745cc93c","lon":119.475555,"orderNo":24,"relationId":"8760369f-46bf-48f1-8822-f5b5745cc93c","siteId":"1857","siteName":"阳光城市","stream":1},{"lat":31.451242,"lineId":"1","lineStreamSite":"90a53c49-bddf-4a85-a6f5-b81d80876d92","lon":119.4637,"orderNo":17,"relationId":"90a53c49-bddf-4a85-a6f5-b81d80876d92","siteId":"228","siteName":"泓口村","stream":1}],"retCode":0};
				if (data.retCode!=0) {
					$.alert(data.message);
					$.AMUI.progress.done();
					return;
				}
				
				var items = new Array();
				for(var i=0;i<data.result.length;i++){
					var item = data.result[i];
					if(item.stream == stream){
						items.push(item);
					}
				}
			
				
				items.sort(function(a,b){
					return a.orderNo>b.orderNo?1:-1;
				});
				
				data.result = items;
				var myTemplate = Handlebars.compile($('#list-site-templ')
						.html());
				var html = myTemplate(data);
				$('#sites').html(html);
				$.AMUI.progress.done();

			});
		}
		
		function flushLineInfo(lineId) {
			var url = 'taxi/json/nanda?url='+escape("busLineInfo.action?lineId="+lineId+"&typeId=&lineName=");
			var params = {};
			$.request(url,params,function(data) {
				data = JSON.parse(data);
				//var data = {"result":[{"dispatches":90,"downDistance":0,"endSiteId":"14","endSiteId1":"2518","endSiteName":"胥泊村","endSiteName1":"汽车总站","endStation":"14","firstTime":"060000","interval":8,"lastTime":"174000","lineId":"1","lineName":"1","mileage":9,"price":1,"startSiteId":"2518","startSiteId1":"14","startSiteName":"汽车总站","startSiteName1":"胥泊村","startStation":"2518","startTime":"20141223000000","typeId":"2001","upDistance":0,"vehicleAmount":10}],"retCode":0};
				if(data.retCode != 0){
					alert("获取线路信息失败");
					return;
				}
				data = data.result[0];
				var firstTime = data.firstTime1;
				var lastTime = data.lastTime1;
				if(stream==0) {
					$("#goto").html(data.endSiteName);
				} else {
					$("#goto").html(data.endSiteName1);
					firstTime = data.firstTime2;
					lastTime = data.lastTime2;
				}
				firstTime = firstTime?firstTime:'';
				lastTime = lastTime?lastTime:''; 
				$("#title").html(data.lineName);
				$("#firstLastCar").html("首末班车：&nbsp;" + firstTime +"-" + lastTime);
				$("#allprice").html("全程票价：&nbsp;" + data.price + "元");
			});
		}
		
		function changeTarget() {
			var oldUrl = window.location.href;
			var url = oldUrl.substring(0, oldUrl.indexOf("?"));
			if(stream==0) {
				stream=1;
			} else {
				stream=0;
			}
			var newUrl = url + "?lineId="+lineId+"&stream="+stream+"&siteId=" + qsiteId
					+"&longitude="+longitude+"&latitude="+latitude+"&phone="+phone+"&siteName="+escape(siteName);
			window.location.href = newUrl + "&tt="+Math.random();
		}
		
		//收藏、取消收藏
		function shouc(obj) {
			if(!phone || phone=='') {
				$.alert("手机号不能为空");
				return;
			}
			var url = "taxi/json/addBusCollection";
			var params = {lineId:lineId,siteId:qsiteId,phone:phone};
			$.request(url,params,function(data) {
				if(data.retCode != 0){
					$.alert(data.message);
					return;
				}
				$(obj).hide();
				$(obj).next().show();
				$.alert("收藏成功");
			});
		}
	
		function qxshouc(obj) {
			if(!phone || phone=='') {
				$.alert("手机号不能为空");
				return;
			}
			var url = "taxi/json/delBusCollection";
			var params = {lineId:lineId,siteId:qsiteId,phone:phone};
			$.request(url,params,function(data) {
				if(data.retCode != 0){
					$.alert('取消收藏失败');
					return;
				}
				$(obj).hide();
				$(obj).prev().show();
				$.alert("取消成功");
			});
		}
		
		if (!lineId) {
			$.alert('缺少参数');
		} else {
			flushSites(lineId,stream);
			flushLineInfo(lineId);
			setInterval(function(){
				flushLineStatus(lineId);
			},2000);
			setInterval(function(){
				relocate();
			},30*1000);
		}
		
		$("#sy").click(function(){
			location.href = "bus.html?longitude=" + longitude + "&latitude=" + latitude + "&phone=" + phone + "&tt="+Math.random();
		});
		
		$("#xlgh").click(function(){
			location.href = "bustransfer.html?longitude=" + longitude + "&latitude=" + latitude + "&phone=" + phone + "&tt="+Math.random();
		});
		
		$("#wdsc").click(function(){
			location.href = "collection.html?longitude=" + longitude + "&latitude=" + latitude + "&phone=" + phone + "&tt="+Math.random();
		});
		
		$("#schedule").click(function(){
			location.href = "busSchedule.html?lineId="+lineId + "&stream="+stream+"&siteId="+qsiteId+"&longitude=" + longitude + "&latitude=" + latitude + "&phone=" + phone + "&tt="+Math.random();
		});
		
		function relocate(){
			if($.isIOS()){
				if(navigator.geolocation){
		        	navigator.geolocation.getCurrentPosition(
						function(p){
			            	longitude = p.coords.longitude;
							latitude = p.coords.latitude;
						},
			            function(e){
			            	var msg = e.code + "," + e.message;
			            	$.alert('获取位置失败：'+msg);
						}
		        	);
			    } else {
			    	$.alert('获取位置失败');
			    	return;
			    }
			} else {
				var url = '';
				var params = {};
				$.asyncrequest(url,params,function(data){
					if(data.retCode!=0){
						$.alert('获取位置失败');
						return;
					}
					longitude = data.longitude;
					latitude = data.latitude;
				});
			}
			var url = 'taxi/json/nanda?url='+escape("getNearestSite.action?lat="+latitude+"&lon="+longitude+"&coordinate=3");
			var params = {};
			$.request(url, params, function(data){
				data = JSON.parse(data);
				if(data.retCode!=0 || data.result.length<=0){
					return;
				}
				siteName = data.result[0].siteName;
			});
		}
	</script>


</body>
</html>
